/**
 * 获取当前的时间戳
 */
function getCurrentTimestamp() {
    return new Date().getTime();
}

/**
 * 获取加密函数
 * @param {*} params 请求相关参数
 * @param {*} timestamp  当前时间戳
 * @param {*} apiKey  规定字符串
 */
function getSign(params, timestamp, apiKey) {
    if (typeof params === "string") {
        return paramsStrSort(params, timestamp, apiKey);
    } else if (typeof params === "object") {
        var arr = [];
        for (var i in params) {
            arr.push((i + "=" + params[i]));
        }
        arr.push(("timestamp" + "=" + timestamp));
        return paramsStrSort(arr.join(("&")), apiKey);
    }
}

function paramsStrSort(paramsStr, apiKey) {
    var urlStr = paramsStr.split("&").sort().join("&");
    var newUrl = urlStr + '&apiKey=' + apiKey;
    return $.md5(newUrl);
}